$(function () {
    //变量抽取
    var claim_dataGrid = $("#claim_dataGrid");

    claim_dataGrid.datagrid({
        url:'/claimReport/list',
        columns:[[
            {field: 'groupByType', title: '分组类型', width:100, align: 'center',formatter: function (value, row, index) {
                    //console.log(value);
                    //console.log(row);
                    if (value) {
                        return value;
                    } else {
                        return "获取分组类型失败";
                    }
                }
            },
            {field: 'totalAmount', title: '索赔总金额', width: 100, align: 'center'},
        ]],
        fit:true,
        fitColumns: true,//列自适应
        toolbar: "#tb",//工具
        pagination: true,//分页
        rownumbers: true,//行号
        singleSelect: true//只允许选择一行
    });

    var methodObj = {
        search: function () {
            //获取文本框中的值
            var companyId = $("[name=companyId]").val();
            var beginDate = $("[name=beginDate]").val();
            var endDate = $("[name=endDate]").val();
            var groupByType = $("[name=groupByType]").val();
            console.log(groupByType);
            claim_dataGrid.datagrid('load',{
                companyId: companyId,
                beginDate:beginDate,
                endDate:endDate,
                groupByType:groupByType
            });
        },
        reload:function () {
            claim_dataGrid.datagrid("load",{});
            $(".clean").combobox("clear");
            $(".dateclean").datebox("clear");
        },
        bar:function () {
            /*点击序列化表单,并且在子窗口中打开拼接的连接地址*/
            var url = "/claimReport/claimbar";  //显示柱状图的路径

            url = url + "?" + $("#claimForm").serialize();

            art.dialog.open(url,{
                width: 650,
                height: 450
            });
        },

        pie:function () {
            /*点击序列化表单,并且在子窗口中打开拼接的连接地址*/
            var url = "/claimReport/claimpie";  //显示饼状图的路径
            url = url + "?" + $("#claimForm").serialize();
            art.dialog.open(url,{
                width: 630,
                height: 450
            });

        }
    }
    //按钮统一绑定事件
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        methodObj[cmd]();
    })
})